﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quartz;
using Quartz.Impl;


public class CronJob : IJob
{

    #region IJob Members

    public void Execute(JobExecutionContext context)
    {
        try
        {
            new Abalone.Common.Scheduler.ScheduledJobAspService().ScheduledJobTimerElapsed();
        }
        catch (Exception ex)
        {
            JobExecutionException qe = new JobExecutionException(ex);
            qe.RefireImmediately = true;  // this job will refire immediately
            throw qe;

        }
    }
    #endregion
}


public class JobScheduler
{
    public static void Start()
    {
        IScheduler scheduler = StdSchedulerFactory.DefaultScheduler;
        scheduler.Start();
        JobDetail job = new JobDetail("Test", "Text", typeof(CronJob), true, true, true);       
        Trigger trigger = TriggerUtils.MakeSecondlyTrigger(30);
        trigger.StartTimeUtc = DateTime.UtcNow;
        trigger.Name = "Daily Trigger";
        scheduler.ScheduleJob(job, trigger);
    }
}

